﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Serilog;


namespace GpCommon.Logger
{
    public static class Logger
    {

        private static ILogger _logger;
        static Logger()
        {
            //日志记录
            _logger = new LoggerConfiguration()
                        .WriteTo.File("logs/GpToolLog.txt", rollingInterval: RollingInterval.Day)
                        .CreateLogger();
        }
        public static void Error(string msg)
        {
            _logger.Error(msg);
        }
        public static void Error(Exception ex)
        {
            StringBuilder stringBuilder = new StringBuilder();
            stringBuilder.Append("【ExMessage】:" + ex.Message + ";");
            stringBuilder.Append("【StackTrace】:" + ex.StackTrace + ";");
            _logger.Error(stringBuilder.ToString());
        }
        public static void Warning(string msg)
        {
            _logger.Warning(msg);
        }
        public static void Info(string msg)
        {
            _logger.Information(msg);
        }
    }
}
